clear all
set more off
use "$inputs/prowess/Energy Consumption.dta", clear
rename energy_cons_unit8 unit1
replace unit1=upper(unit1)
merge m:1 unit1 using "$inputs/handcoded/unit_conversion.dta"
keep if _merge ==3
drop _merge unit1
rename unit Unit
rename energy_name4 energy_cons_name
merge m:1 energy_cons_name Unit using "$inputs/handcoded/energy_content.dta"
keep if _merge == 3
drop _merge
gen energy_cons_quantity = (energy_cons_qty7 * energy_content_MJ) * (conversion)
collapse (sum) energy_cons_quantity energy_cons_value9, by(totener_cocode1 totener_date3)
rename totener_cocode1 products_cocode1 
rename totener_date3 prod_date3
save "$working/en.dta", replace
